package com.csipsimple.phone;


// importer R
import com.urnum.R;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;


 
public class CallAnswerActivity extends Activity {

	/**
	 * internal phone state broadcast receiver
	 */
	protected BroadcastReceiver r;
	
	@Override protected void onCreate(Bundle savedInstanceState) {
		
		requestWindowFeature(Window.FEATURE_NO_TITLE); 
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.callanswerscreen);
		
		Window w = this.getWindow();
		w.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); 
		w.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 
		w.setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

		Button returnToCallScreen = (Button) findViewById(R.id.returnToCallScreen);
		returnToCallScreen.setOnClickListener(new ReturnButtonOnClickListener());
		
	}
	
	@Override public boolean onTouchEvent(MotionEvent event)  
	{  
	   	       if(event.getAction() == MotionEvent.ACTION_OUTSIDE){  
	    	   exitCleanly();	       }  
	       return false;  
	}  

	/**
	 * Return button click listener will exit back to the
	 * phones stock answer call application.
	 */
	private class ReturnButtonOnClickListener implements OnClickListener {
		@Override public void onClick(View v) {
			exitCleanly();
		}
	}

	
	/** 
	 * cleanup and exit routine
	 */
	private void exitCleanly() {
		moveTaskToBack(true);		
		finish();
	}

}